/******************************************************文本框*****************************************************/
/*
 依赖
 <script type="text/javascript" src="../static/lib/ueditor/ueditor.config.js"></script>
 <script type="text/javascript" src="../static/lib/ueditor/ueditor.all.js"></script>
 <script type="text/javascript" src="../static/lib/ueditor/lang/zh-cn/zh-cn.js"></script>
 */
_$.Editor=function (target){
    var _this = this;
    _$.Editor.superclass.constructor.call(_this,target);
};
_$.regClass("Editor",_$.Editor);

_$.extend(_$.Editor,_$.FormItem, {
    _cls:_$._clsPre + "Editor",
    _uiCls:_$._uiPreCls + "Editor",
    _attrProps:function(){
        var _this = this;
        var properties = _$.Editor.superclass._attrProps.call(_this);
        properties.addAll(["onfocus","oninput","onblur","onchange","inputStyle"]);
        return properties;
    },
    _attrOpts:function(){
        var _this = this;
        var opts = _$.Editor.superclass._attrOpts.call(_this);
        return $.extend(true,opts,{

        });
    },
    _editModel:function(){
        var _this = this;
        _this._clearShow();

        var source='<script type="text/plain" id="editor_'+_this.id+'" style="width:600px;;height:150px;"></script>';
        _this._replaceNode(source);

        var ue = UE.getEditor("editor_"+_this.id, {
            autoHeight: false
        });
        _this.component = ue;
        _this.el.addClass(_this._uiCls);
        _this.setOption("model",_EDITABLE_);
        _this._init();
        _this._bindEvents();
    },
    _bindEvents:function(){

    },
    setValue:function(value) {
        var _this = this;
        if(isEmpty(value)){
            _this.value = null;

            if (_this._isEdit()) {

                _this.component.ready(function() {
                    _this.component.setContent("");
                });

            } else {
                _this.component.html("");
            }
        }else{
            _this.value = value;
            if (_this._isEdit()) {

                _this.component.ready(function() {
                    _this.component.setContent(value);
                });
            } else {
                _this.component.html(value);
            }
        }
    },
    _sync:function(){
        var _this = this;
        _this.component.ready(function() {
            var html = _this.component.getContent();
            _this.value = html;
        });
    },
    getValue:function(){
        var _this = this;
        if(_this._isEdit()){
            _this._sync();
        }
        return _this.value;
    }
});
